﻿using FlowCanvas;
using FlowCanvas.Nodes;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.AI;
using Yoozoo.Gameplay.Liberty.StreetEvent;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    public class GetAIEntityTransform : CallableActionNodeBase
    {
        private int uniqueId;
        
        protected override void OnRegisterPorts(FlowNode node)
        {
            var p1 = node.AddValueInput<int>("uniqueId");
            node.AddValueOutput("position", () =>
            {
                AIEntity aiEntity = LibertyAIUtils.GetNpc(p1.value);
                if (aiEntity && aiEntity.viewer.animator)
                {
                    return aiEntity.viewer.animator.transform.position;
                }
                return Vector3.zero;
            });
            node.AddValueOutput("rotation", () =>
            {
                AIEntity aiEntity = LibertyAIUtils.GetNpc(p1.value);
                if (aiEntity && aiEntity.viewer.animator)
                {
                    return aiEntity.viewer.animator.transform.rotation;
                }
                return Quaternion.identity;
            });
        }
        
    }
}